import { Body, Controller, HttpCode, HttpStatus, Logger, Post } from '@nestjs/common';
import { ApiOperation, ApiTags } from '@nestjs/swagger';
import { LoginService } from '../services/login.service';
import { LoginDto } from './dto/login.dto';

@ApiTags('后台管理系统--用户登录')
@Controller('login')
export class LoginController {
  private readonly logger: Logger = new Logger(LoginController.name);
  // private readonly logg
  constructor(private readonly loginService: LoginService) {}

  @ApiOperation({
    summary: '用户登录',
    description: '用户名可以是手机号、用户名',
  })
  @HttpCode(HttpStatus.OK)
  @Post()
  async login(@Body() loginDto: LoginDto) {
    // this.logger.log('接收的登录参数：', loginDto);
    return this.loginService.adminLogin(loginDto);
  }
}
